// ---------------------------------------------------------------------
//
// -- 用户头像
// -- author £
//
// ---------------------------------------------------------------------

const FADE_TIME = 0.2;

cc.Class({
    extends: cc.Component,

    properties: {
        head: cc.Sprite,
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this.node.active = false;
    },

    start () {

    },

    setHead: function (data) {
        if (data.url && data.id) {
            require('Platform').setHead(data.url, data.id, this.head);
        }
    },

    hide: function (directly) {
        if (directly) {
            this.node.active = false;
            return;
        }

        require('ActionLib').FADE_HIDE(
            this.node, FADE_TIME, null,
            null, this, null, true
        );
    },

    show: function (data) {
        this.setHead(data);
        this.node.active = true;
        require('ActionLib').FADE_SCALE_SHOW(
            this.node, FADE_TIME
        );
    },

    // update (dt) {},
});
